
package std.fs

import std.collection.*
import std.io.*
import std.time.*
import std.io.IOException

/**
* @throws IllegalMemoryException
* @throws IndexOutOfBoundsException
* @throws IllegalArgumentException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func copy(sourcePath: Path, to!: Path, overwrite!: Bool = false): Unit

/**
* @throws IllegalMemoryException
* @throws IndexOutOfBoundsException
* @throws IllegalArgumentException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func copy(sourcePath: String, to!: String, overwrite!: Bool = false): Unit

/**
* @throws IllegalArgumentException
* @throws IllegalMemoryException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func remove(path: Path, recursive!: Bool = false): Unit

/**
* @throws IllegalArgumentException
* @throws IllegalMemoryException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func remove(path: String, recursive!: Bool = false): Unit

/**
* @throws IllegalMemoryException
* @throws IllegalArgumentException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func exists(path: Path): Bool

/**
* @throws IllegalMemoryException
* @throws IllegalArgumentException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func exists(path: String): Bool

/**
* @throws IndexOutOfBoundsException
* @throws IllegalMemoryException
* @throws FSException
* @throws IllegalArgumentException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func rename(sourcePath: String, to!: String, overwrite!: Bool = false): Unit

/**
* @throws IndexOutOfBoundsException
* @throws IllegalMemoryException
* @throws FSException
* @throws IllegalArgumentException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func rename(sourcePath: Path, to!: Path, overwrite!: Bool = false): Unit

/**
* @throws IllegalArgumentException
* @throws IllegalMemoryException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func removeIfExists(path: Path, recursive!: Bool = false): Bool

/**
* @throws IllegalArgumentException
* @throws IllegalMemoryException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func removeIfExists(path: String, recursive!: Bool = false): Bool

@!APILevel[
    since: "22"
]
public class Directory {
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(path: String, recursive!: Bool = false): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(path: Path, recursive!: Bool = false): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func createTemp(directoryPath: String): Path
    
    /**
    * @throws IllegalMemoryException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func createTemp(directoryPath: Path): Path
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func isEmpty(path: Path): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func isEmpty(path: String): Bool
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: Path): Array<FileInfo>
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: String): Array<FileInfo>
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func walk(path: Path, f: (FileInfo) -> Bool): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func walk(path: String, f: (FileInfo) -> Bool): Unit
}

@!APILevel[
    since: "22"
]
public enum OpenMode <: ToString & Equatable<OpenMode> {
    @!APILevel[
        since: "22"
    ]
    Read |
    @!APILevel[
        since: "22"
    ]
    Write |
    @!APILevel[
        since: "22"
    ]
    Append |
    @!APILevel[
        since: "22"
    ]
    ReadWrite
    @!APILevel[
        since: "22"
    ]
    public operator func ==(that: OpenMode): Bool
    
    @!APILevel[
        since: "22"
    ]
    public operator func !=(that: OpenMode): Bool
    
    @!APILevel[
        since: "22"
    ]
    public func toString(): String
}

@!APILevel[
    since: "22"
]
public struct FileDescriptor {
    @!APILevel[
        since: "22"
    ]
    public prop fileHandle: IntNative
}

@!APILevel[
    since: "22"
]
public class File <: Resource & IOStream & Seekable {
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(path: String, mode: OpenMode)
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(path: Path, mode: OpenMode)
    
    @!APILevel[
        since: "22"
    ]
    public prop info: FileInfo
    
    @!APILevel[
        since: "22"
    ]
    public prop fileDescriptor: FileDescriptor
    
    @!APILevel[
        since: "22"
    ]
    public prop length: Int64
    
    /**
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func setLength(length: Int64): Unit
    
    /**
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func read(buffer: Array<Byte>): Int64
    
    /**
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(buffer: Array<Byte>): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func flush(): Unit
    
    /**
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func seek(sp: SeekPosition): Int64
    
    @!APILevel[
        since: "22"
    ]
    public func canRead(): Bool
    
    @!APILevel[
        since: "22"
    ]
    public func canWrite(): Bool
    
    /**
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func close(): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func isClosed(): Bool
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(path: Path): File
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(path: String): File
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func createTemp(directoryPath: String): File
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func createTemp(directoryPath: Path): File
    
    /**
    * @throws IllegalMemoryException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: Path): Array<Byte>
    
    /**
    * @throws IllegalMemoryException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: String): Array<Byte>
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func writeTo(path: Path, buffer: Array<Byte>): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func writeTo(path: String, buffer: Array<Byte>): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func appendTo(path: Path, buffer: Array<Byte>): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func appendTo(path: String, buffer: Array<Byte>): Unit
}

@!APILevel[
    since: "22"
]
public struct FileInfo <: Equatable<FileInfo> {
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(path: Path)
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(path: String)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop name: String
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop parentDirectory: Option<FileInfo>
    
    @!APILevel[
        since: "22"
    ]
    public prop path: Path
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop creationTime: DateTime
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop lastAccessTime: DateTime
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop lastModificationTime: DateTime
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop size: Int64
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isSymbolicLink(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isRegular(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isDirectory(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isReadOnly(): Bool
    
    /**
    * @throws IllegalMemoryException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isHidden(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func canExecute(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func canRead(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func canWrite(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func setExecutable(executable: Bool): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func setReadable(readable: Bool): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalMemoryException
    * @throws FSException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func setWritable(writable: Bool): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public operator func ==(that: FileInfo): Bool
}

@!APILevel[
    since: "22"
]
public class FSException <: IOException {
    @!APILevel[
        since: "22"
    ]
    public init()
    
    @!APILevel[
        since: "22"
    ]
    public init(message: String)
}

@!APILevel[
    since: "22"
]
public class HardLink {
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(link: Path, to!: Path): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(link: String, to!: String): Unit
}

/**
* @throws IllegalMemoryException
* @throws IndexOutOfBoundsException
* @throws IllegalArgumentException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func canonicalize(path: String): Path

/**
* @throws IllegalArgumentException
* @throws IllegalMemoryException
* @throws IndexOutOfBoundsException
* @throws FSException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func canonicalize(path: Path): Path

@!APILevel[
    since: "22"
]
public struct Path <: Equatable<Path> & Hashable & ToString {
    @!APILevel[
        since: "22"
    ]
    public static const Separator: String = PATH_SEPARATOR
    
    @!APILevel[
        since: "22"
    ]
    public static const ListSeparator: String = PATH_LISTSEPARATOR
    
    @!APILevel[
        since: "22"
    ]
    public init(rawPath: String)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop parent: Path
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop fileName: String
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop extensionName: String
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop fileNameWithoutExtension: String
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isAbsolute(): Bool
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isRelative(): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22"
    ]
    public func join(path: String): Path
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22"
    ]
    public func join(path: Path): Path
    
    @!APILevel[
        since: "22"
    ]
    public func isEmpty(): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func normalize(): Path
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public operator func ==(that: Path): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func hashCode(): Int64
    
    @!APILevel[
        since: "22"
    ]
    public func toString(): String
}

@!APILevel[
    since: "22"
]
public class SymbolicLink {
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(link: Path, to!: Path): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func create(link: String, to!: String): Unit
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: String, recursive!: Bool = false): Path
    
    /**
    * @throws IllegalMemoryException
    * @throws IndexOutOfBoundsException
    * @throws FSException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public static func readFrom(path: Path, recursive!: Bool = false): Path
}



